The DIALOG_COLORPICKER function allows you to interactively select a color using a selection dialog. The basic dialog grid includes 64 standard colors. You can set custom and preferred colors using keywords.
Open the Select Color dialog. Type:
result = DIALOG_COLORPICKER()
This opens the generic Select Color dialog.
See Additional Examples for additional examples using the DIALOG_COLORPICKER function.
Result = DIALOG_COLORPICKER( [, BOX_SIZE=variable] [, COLORS=array] [, CUSTOM_COLORS=array] [, CUSTOM_TITLE=string] [, CUSTOM_OUT=variable] [, DIALOG_PARENT=widget_id] [, /FRAMELESS] [, /MODAL] [, NCOLS=variable] [, NROWS=variable] [, PREFERRED_COLORS=array] [, PREFERRED_TITLE=string] [, TITLE=string] [, WCALLER=variable] [, XOFFSET=variable] [, YOFFSET=variable]
DIALOG_COLORPICKER returns the color that was chosen as a three-element vector containing the RGB color.
Set the size, in pixels, of each color swatch.
Specify the colors to use in the primary color grid area, if you want to override the 64 colors in the default basic grid with different colors. This is a 3 x n array, where n is the number of RGB triplets for the colors.
Set this keyword to an array or list of custom colors. This is a 3 x n array, where n is the number of RGB triplets for the colors. If CUSTOM_COLORS is a list, each element must be a three-element vector containing an RGB color.
Set this keyword to a string giving the title of the custom color section.
Set this keyword to a named variable that will contain the new array of custom colors if a new custom color was added.
Set this keyword to the widget ID of a widget to be used as the parent of this dialog.
If set, this dialog will not have a window frame around it. This keyword is ignored if MODAL is set.
Note: This is a suggestion to the windowing system and may be ignored.
If set, this dialog will be modal. This keyword is ignored if WCALLER is not set. If this keyword is set, FRAMELESS will be ignored.
Specify the number of columns in the color grid. The default is 8.
Specify the number of rows in the color grid. The default is 8.
Set an array of preferred colors. This is a 3 x n array, where n is the R,G,B values for the color. These colors will appear in a separate line above the primary system color area.
Set this keyword to a string giving the title of the preferred color section.
Set this keyword to a scalar string to be used for the dialog title. If it is not specified, the default title is "Select Color."
If set to the Widget ID of the calling widget, this dialog will try to position itself just below the calling widget. If the calling widget is modal, this will also set the FRAMELESS and MODAL keywords to this dialog. If XOFFSET or YOFFSET are set they will override any positioning based on the calling widget.
The X offset of the widget in pixels, relative to the screen.
The Y offset of the widget in pixels, relative to the screen.
This example shows the use of the WCALLER keyword. By passing the widget ID of the widget button used to call the DIALOG_COLORPICKER, the dialog will appear just below the button.
pro dcp_test_event, ev
wText = WIDGET_INFO(ev.top, FIND_BY_UNAME='text')
WIDGET_CONTROL, wText, SET_VALUE='No color selected'
color = DIALOG_COLORPICKER(WCALLER=ev.id)
if (color.length eq 3) then $
WIDGET_CONTROL, wText, $
SET_VALUE='Color: [' + (color.toString()).join(',') + ']'
end
pro dcp_test
wTlb = WIDGET_BASE(/COLUMN)
wButton = WIDGET_BUTTON(wTlb, value='Select Color')
wText = WIDGET_TEXT(wTlb, value='', XSIZE=50, UNAME='text')
WIDGET_CONTROL, wTlb, /REALIZE
xmanager, 'dcp_test', wTlb, /NO_BLOCK
end
|
8.5 |
Introduced |